# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/25 22:17
# @Author   : Robot-Zsj
"""
description:

i:
12 7 2 1 1 -1 13
001000010000
001000010000
001000010000
001000010000
001000010000
001000010000
001000010000


o:
3
"""

w, h, x, y, sx, sy, t = map(int, input().split())
matrix = [input() for _ in range(h)]


def getResult():
    global x, y, sx, sy, t

    ans = 0

    while t >= 0:
        if matrix[y][x] == '1':
            ans += 1

        y += sy
        x += sx

        if x < 0:
            x = 1
            sx = -sx

        elif x >= w:
            x = w - 2
            sx = -sx

        if y < 0:
            y = 1
            sy = -sy

        elif y >= h:
            y = h - 2
            sy = -sy

        t -= 1
    return ans


print(getResult())
